package org.jsola.hr;

import org.jsola.hr.interceptor.HrCrmJurisdictionInterceptorAdapter;
import org.jsola.hr.interceptor.HrSiteExpireInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author wu
 */
@SpringBootConfiguration
public class HrSiteExpireInter implements WebMvcConfigurer {

    @Autowired
    private HrSiteExpireInterceptor hrSiteExpireInterceptor;

    @Autowired
    private HrCrmJurisdictionInterceptorAdapter hrCrmJurisdictionInterceptorAdapter;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(hrSiteExpireInterceptor).addPathPatterns("/**")
                .excludePathPatterns("/user/api/v1/login/**", "/user/api/v1/token/switch", "/hr/api/v1/login/**");
        registry.addInterceptor(hrCrmJurisdictionInterceptorAdapter).addPathPatterns("/hr/api/v1/crmCustomerDistributionRecords/**", "/hr/api/v1/crmCustomerImportDetails/**"
                , "/hr/api/v1/crmCustomerImportRecords/**", "/hr/api/v1/crmCustomerInfos/**", "/hr/api/v1/crmMembers/**", "/hr/api/v1/crmMemberRelations/**"
                , "/hr/api/v1/crmOperationRecords/**", "/hr/api/v1/crmVisitRecords/**")
                .excludePathPatterns("/hr/api/v1/crmMembers/getMyJurisdiction");

    }

}
